home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 424_02 / ED-157 / left_arrow.c < prev    next >
C/C++ Source or Header  |  1993-09-10  |  2KB  |  57 lines

  1. /*
  2.  * Copyright (C) 1992 by Rush Record (rhr@clio.rice.edu)
  3.  * 
  4.  * This file is part of ED.
  5.  * 
  6.  * ED is free software; you can redistribute it and/or modify it under the terms
  7.  * of the GNU General Public License as published by the Free Software Foundation.
  8.  * 
  9.  * ED is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  10.  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  11.  * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  12.  * 
  13.  * You should have received a copy of the GNU General Public License along with ED
  14.  * (see the file COPYING).  If not, write to the Free Software Foundation, 675
  15.  * Mass Ave, Cambridge, MA 02139, USA.
  16.  */
  17. #include "opsys.h"
  18.  
  19. #include "rec.h"
  20. #include "window.h"
  21. #include "ed_dec.h"
  22.  
  23. /******************************************************************************\
  24. |Routine: left_arrow
  25. |Callby: edit insert word_fill
  26. |Purpose: Does what is required to move the cursor to the left. If the cursor
  27. |         is at the beginning of a record, moves it to the end of the previous
  28. |         record.
  29. |Arguments:
  30. |    repeat is the repeat count for the action.
  31. \******************************************************************************/
  32. void left_arrow(repeat)
  33. Int repeat;
  34. {
  35.     register Int i;
  36.  
  37.     i = repeat;
  38.     while(CURBYT < i)
  39.     {
  40.         i -= CURBYT + 1;
  41.         if(CURREC->prev == BASE)
  42.         {
  43.             CURBYT = i;
  44.             abort_key();
  45.             break;
  46.         }
  47.         CURREC = CURREC->prev;
  48.         CURBYT = CURREC->length;
  49.         CURROW--;
  50.     }
  51.     CURBYT -= i;
  52.     CURCOL = get_column(CURREC,CURBYT);
  53.     WANTCOL = CURCOL;
  54.     fix_display();
  55. }
  56.  
  57.